package array;

public class leetCode66_plusOne {
    public static void main(String[] args) {
        int[] nums = {9,9};
        leetCode66_plusOne a = new leetCode66_plusOne();
        int[] ints = a.plusOne(nums);
        System.out.println(1);
    }
    public int[] plusOne(int[] digits) {
        if(digits == null || digits.length == 0) return new int[]{1};
        int n = digits.length;
        for (int i = n - 1; i >= 0; i--) {
           digits[i]++;
           digits[i] = digits[i]%10;
           if(digits[i] != 0) return digits;
        }
        digits = new int[digits.length + 1];
        digits[0] = 1;
        return digits;
    }
}
